package Sources;

import java.nio.file.InvalidPathException;
import java.util.List;

import System.Listener;

/**
 * This class adds new functionality to the class Sources .
 * the other classes don't know  class Sources ,and work with the listening 
 * sources through SourcesAdapter .
 */
public class SourcesAdapter {
	Sources instance=null;
	Listener listener=null;
	public SourcesAdapter(Sources input,Listener listen) {
		instance=input;
		listener=listen;
		System.out.println("Adapter init\n");
	}
	//Add a new source to listen to
	public void insertSource(String path,String[] exp) throws InvalidPathException{
		System.out.println("Adapter ok\n");
		instance.insertSource(path,exp);
		//if path is incorrect exception is thrown before this line so if we here it's correct
		listener.execute(path,exp);
		
	}
	
	//Modify an existing listening source
	public void setSource(String from,String to,String[] exp){
		instance.setSource(from,to,exp);
	}
	//Stop listening to this source
	public void deleteSource(String what) {
		instance.deleteSource(what);
	}
	//Dump the sources list
	public List<String> dumpSource() {
		return instance.getSources();
	}
}